package com.example.security.social;

import org.springframework.social.security.SocialAuthenticationFilter;
import org.springframework.social.security.SpringSocialConfigurer;

public class LoginSpringSocialConfigurer extends SpringSocialConfigurer {
    /**
     * 这是SpringSocial过滤器
     * 该方法是将SpringSocial里面默认的第三方登录的路径，改成自定义
     */

    //从构造函数将处理的url传进来，根据不同的登录方式qq，weixin
    private String filterProcessesUrl;
    public LoginSpringSocialConfigurer(String filterProcessesUrl){
        this.filterProcessesUrl = filterProcessesUrl;
    }

    @Override
    protected <T> T postProcess(T object) {
        //这个object就是要放到过滤器链上的SpringSocialAuthenticationFilter
        SocialAuthenticationFilter filter = (SocialAuthenticationFilter)super.postProcess(object);
        filter.setFilterProcessesUrl(filterProcessesUrl);
        return (T)filter;
    }
}
